﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Meqs.Entity;
using Meqs.Entity.Views;
using Meqs.Logic.Interface;
using Meqs.Utilities;

public partial class Moral_Teacher_Reprots_ClassHealth : ReportBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        InitGradeSelect();
    }

    /// <summary>
    /// 初始化年级选择下拉框
    /// </summary>
    private void InitGradeSelect()
    {
        Hashtable ht = new Hashtable();
        ht.Add("SchoolMark", SchoolMark);
        IList<SchoolInfo> schoolList = Container<ISchoolInfoLogic>.Instance.FindAll(ht);
        switch (schoolList[0].SchoolOpt)
        {
            case 1:
                selGrade.Items.Add(new ListItem("一年级", "1"));
                selGrade.Items.Add(new ListItem("二年级", "2"));
                selGrade.Items.Add(new ListItem("三年级", "3"));
                selGrade.Items.Add(new ListItem("四年级", "4"));
                selGrade.Items.Add(new ListItem("五年级", "5"));
                selGrade.Items.Add(new ListItem("六年级", "6"));
                break;
            case 2:
                selGrade.Items.Add(new ListItem("初一", "7"));
                selGrade.Items.Add(new ListItem("初二", "8"));
                selGrade.Items.Add(new ListItem("初三", "9"));
                break;
            case 3:
                selGrade.Items.Add(new ListItem("高一", "10"));
                selGrade.Items.Add(new ListItem("高二", "11"));
                selGrade.Items.Add(new ListItem("高三", "12"));
                break;
            case 4:
                selGrade.Items.Add(new ListItem("一年级", "1"));
                selGrade.Items.Add(new ListItem("二年级", "2"));
                selGrade.Items.Add(new ListItem("三年级", "3"));
                selGrade.Items.Add(new ListItem("四年级", "4"));
                selGrade.Items.Add(new ListItem("五年级", "5"));
                selGrade.Items.Add(new ListItem("六年级", "6"));
                selGrade.Items.Add(new ListItem("初一", "7"));
                selGrade.Items.Add(new ListItem("初二", "8"));
                selGrade.Items.Add(new ListItem("初三", "9"));
                break;
            case 5:
                selGrade.Items.Add(new ListItem("初一", "7"));
                selGrade.Items.Add(new ListItem("初二", "8"));
                selGrade.Items.Add(new ListItem("初三", "9"));
                selGrade.Items.Add(new ListItem("高一", "10"));
                selGrade.Items.Add(new ListItem("高二", "11"));
                selGrade.Items.Add(new ListItem("高三", "12"));
                break;
        }
    }


    protected void btnFlash_Click(object sender, EventArgs e)
    {
        int schoolYear = 0;
        int term = 0;
        int week = 0;
        int grade = 0;
        if (!Int32.TryParse(txtSchoolYear.Text, out schoolYear))
            return;
        if (!Int32.TryParse(txtTerm.Text, out term))
            return;
        if (!Int32.TryParse(txtWeek.Text, out week))
            return;
        if (!Int32.TryParse(selGrade.Text, out grade))
            return;
        


        DateTime startTime = new DateTime();
        DateTime endTime = new DateTime();
        SchoolCommon.GetWeekInTerm(schoolYear, term, SchoolMark, week, out startTime, out endTime);

        IList<GoodCadreView> resultList = Container<IClassEvalTypeCatchLogic>.Instance.FindDayOrWeekReprot(SchoolMark, schoolYear, term, startTime, endTime, grade, "Class_Week_Health");

        CreateTable(tbResult, resultList);
    }

    [WebMethod]
    public static string GetExcel(ExcelTableCell[][] cells)
    {
        string temp_path = HttpContext.Current.Server.MapPath("../../../");
        string save_path = temp_path + "download\\" + DateTime.Now.Ticks.ToString() + "_profile.xls";
        HttpContext.Current.Session["filepath"] = save_path;
        ExcelUtil.ExcelExport(save_path, DateTime.Now.Ticks.ToString() + "大扫除周报表", 2, 0, cells);
        return "";
    }

}
